Java Interview Preparation Roadmap
1. Core Javaโ
| Topic | Subtopics | Example Questions / Practice |
|---|---|---|
| OOP Concepts | Inheritance, Polymorphism (compile/runtime), Abstraction, Encapsulation, Interfaces | Explain runtime vs compile-time polymorphism. Design a shape class hierarchy with method overriding. |
| Java Basics | main method, packages, access modifiers | - Difference between public, private, protected, default.- Explain static keyword and its use cases. |
| Data Types & Variables | Primitive vs Wrapper, autoboxing/unboxing | - Difference between int and Integer.- What happens during autoboxing? |
| Strings | String, StringBuilder, StringBuffer, immutability | - Why String is immutable?- Compare StringBuilder vs StringBuffer. |
| Collections Framework | List, Set, Map, Queue, implementations, differences | - Difference between ArrayList and LinkedList.- Implement LRU cache using LinkedHashMap. |
| Generics | Bounded types, wildcards, type erasure | - Difference between ? extends T and ? super T.- Why Java uses type erasure? |
| Exception Handling | Checked vs unchecked, throw vs throws, custom exceptions | - Write a custom exception. - Explain try-with-resources. |
| Java Memory Model | Stack vs Heap, GC, memory leaks, references | - Explain strong, weak, soft, phantom references. - What is a memory leak in Java? |
2. Java 8+ Featuresโ
| Topic | Subtopics | Example Questions / Practice |
|---|---|---|
| Functional Interfaces | Predicate, Function, Consumer, Supplier | - Use Predicate to filter a list of strings starting with โAโ. |
| Lambdas | Syntax, capturing variables, method references | - Convert an anonymous class into a lambda. - Explain this reference inside a lambda. |
| Streams API | Map, filter, reduce, collect, parallel streams | - Count distinct words in a list. - Group employees by department using streams. |
| Optional | Avoiding NPE, ifPresent, orElse | - How to avoid NullPointerException with Optional? |
| Date/Time API | LocalDate, LocalTime, LocalDateTime, formatting | - Calculate days between two dates using java.time. |
3. Multithreading & Concurrencyโ
| Topic | Subtopics | Example Questions / Practice |
|---|---|---|
| Threads | Thread vs Runnable vs Callable, Future | - Implement a multi-threaded task using Callable and Future. |
| Synchronization | synchronized, Locks, Deadlock | - Write a deadlock example and solve it. |
| Executor Framework | ExecutorService, ScheduledExecutorService | - Schedule a task to run every 5 seconds. |
| Concurrent Collections | ConcurrentHashMap, CopyOnWriteArrayList | - Difference between HashMap and ConcurrentHashMap. |
| Java Memory Visibility | volatile, happens-before | - Explain volatile with an example. |
| ForkJoinPool | Divide & conquer parallelism | - Implement parallel sum of an integer array. |
4. Advanced Java / JVMโ
| Topic | Subtopics | Example Questions / Practice |
|---|---|---|
| JVM Internals | Class loading, bytecode, JIT | - Explain JVM memory areas. - What is classloader hierarchy? |
| Garbage Collection | Serial, Parallel, CMS, G1 | - How does G1 GC work? - Explain memory leak examples. |
| Annotations & Reflection | Custom annotations, reflection API | - Create a custom annotation and process it using reflection. |
| Serialization | Serializable, Externalizable, transient | - Explain difference between Serializable and Externalizable. |
| Java Modules | module-info.java, exports, requires | - Explain module system in Java 9+. |
5. Design Patterns & Best Practicesโ
| Topic | Subtopics | Example Questions / Practice |
|---|---|---|
| Design Patterns | Singleton, Factory, Builder, Observer, Strategy | - Implement a thread-safe singleton. - Use Builder pattern to create an object. |
| SOLID Principles | SRP, OCP, LSP, ISP, DIP | - Refactor a class violating SRP. |
| Effective Java Practices | equals()/hashCode(), immutability | - Implement proper equals() and hashCode().- Make a class immutable. |
6. Spring & Hibernate (if applicable)โ
| Topic | Subtopics | Example Questions / Practice |
|---|---|---|
| Spring Core | IoC, DI, Bean lifecycle | - Explain constructor vs setter injection. |
| Spring Boot | Auto-configuration, profiles, starters | - How does Spring Boot simplify app setup? |
| Spring MVC | Controllers, REST API | - Write a REST API to get employee details. |
| Spring Security | Authentication, JWT, OAuth2 | - Implement basic JWT authentication. |
| JPA & Hibernate | Entity lifecycle, caching, relationships | - Map a OneToMany and ManyToOne relationship.- Difference between lazy vs eager fetch. |
7. Common Coding/Design Questionsโ
- Implement LRU Cache using
LinkedHashMap. - Producer-Consumer problem with threads.
- Deadlock demonstration and resolution.
- Custom comparator for sorting.
- Stream-based grouping/filtering/counting problems.
- Thread-safe singleton & object pool implementation.
๐ก Preparation Tips:
- Start with Core Java โ practice coding + conceptual questions.
- Move to Java 8 features + Collections + OOP.
- Dive into Multithreading + Concurrency.
- Cover JVM internals + Garbage Collection + Serialization.
- Finally, Spring/Hibernate + Design Patterns + Advanced coding.